<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class User_model extends CI_Model {

	public function check_login($uname,$pw,$role)
	{
		$this->load->database();
		$sql = "SELECT username,password,activated FROM student_account WHERE username = '$uname' AND password = '".md5($pw)."'"; 
		$query = $this->db->query($sql, array($uname, $pw));
		
		if ($query->num_rows() > 0){
			$row = $query->row(); 
			
			if($role == 3){
				if($row->activated == 0)
					return false;
			}
			return true;
		} else {
			return false;
		}
	}
	
}